package com.gdcn.zb.sys.service.impl;

import java.util.List;
import java.util.Map;

import com.gdcn.zb.base.BaseService;
import com.gdcn.zb.base.exception.DaoException;
import com.gdcn.zb.base.exception.ServiceException;
import com.gdcn.zb.sys.dao.ISekcioDao;
import com.gdcn.zb.sys.dao.ITypeTargetDao;
import com.gdcn.zb.sys.dao.IUserDao;
import com.gdcn.zb.sys.service.ITypeTargetService;
import com.gdcn.zb.sys.service.IUserService;
import com.gdcn.zb.sys.ValidateException;
import com.gdcn.zb.sys.valueobject.Sekcio;
import com.gdcn.zb.sys.valueobject.TypeTarget;
import com.gdcn.zb.sys.valueobject.User;


public class TypeTargetServiceImpl extends BaseService implements ITypeTargetService {
	private ITypeTargetDao typeTargetDao ;
	
	public void setTypeTargetDao(ITypeTargetDao typeTargetDao) {
		this.typeTargetDao = typeTargetDao;
	}
	
	public void createTypeTarget(TypeTarget typeTarget) throws ServiceException {
		try{
			typeTargetDao.createTypeTarget(typeTarget);
		}catch (DaoException e) {
			logger.error(e);
			throw new ServiceException(e);
		}
	}

	public void deleteTypeTarget(int id) throws ServiceException {
		try{
			typeTargetDao.deleteTypeTarget(id);
		}catch (DaoException e) {
			logger.error(e);
			throw new ServiceException(e);
		}
		
	}

	public TypeTarget findTypeTargetById(int id) throws ServiceException {
		TypeTarget typeTarget = null;
		try{
				typeTarget = typeTargetDao.findTypeTargetById(id);
		}catch (DaoException e) {
			logger.error(e);
			throw new ServiceException(e);
		}
		return typeTarget;
	}

	public void updateTypeTarget(TypeTarget typeTarget) {
		try{
			typeTargetDao.updateTypeTarget(typeTarget);
		}catch (DaoException e) {
			logger.error(e);
			throw new ServiceException(e);
		}		
	}
	public List listTypeTargetOfAll() throws ServiceException {
		List<Sekcio> list = null;
		try{
			list = typeTargetDao.listTypeTargetOfAll();
		}catch (DaoException e) {
			logger.error(e);
			throw new ServiceException(e);
		}
		return list;
	}
	
	public void deleteTypeTarget(String[] id) throws ServiceException {
		if(id != null){
			for(int i=0;i<id.length;i++){
				deleteTypeTarget(Integer.parseInt(id[i]));
			}
		}
		
	}


}
